-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ephemeral containers subresource #1153
Conversation
Thanks a lot for this. Having had a quick look it looks generally sensible and fits in with the existing conventions.
hm.. yeah, that is unfortunate. that does not feel like it's expected. maybe there's an upstream issue for it in kubernetes (or maybe no one has noticed it if everyone so far using it has come from client-go). it's another awkward kubernetes api where they expect you to supply one struct, but simultaneously nest it inside a bigger struct they won't use, so i'm sure there are interesting edge cases.
Ah, yeah, we have used the k8s-openapi macros for this before. Here's the last one we removed.
Yeah, I think so. We have other marker traits that are only relevant to pods (like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor nits, interface tweaks, and test structure stuff.
the only thing here that i don't like is the api condition kubernetes is imposing on us (having to append to a vector). if there's any way to get around that through json patches or server-side apply, then that would be a great thing to figure out as a better alternative for us to provide in the docs.
kube-client/src/api/subresource.rs
Outdated
/// #[tokio::main] | ||
/// async fn main() -> Result<(), Box<dyn std::error::Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: These docs can be simplified to use the async wrapper to make it focused on the actual behavior;
/// # async fn wrapper() -> Result<(), Box<dyn std::error::Error>> {
/// let client: Client = todo!();
/// ... actual relevant example part here ; pods, pp, patch
/// Ok(())
/// # }
i realise this is something we have not been consistent about everywhere though and this file is using the old style, so we can probably do that in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good!, I will use the wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Note I am doing the same in core_methods now (but not touching this file to avoid conflicts in this file) in #1158
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty of updating the other sub resource documentation examples as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might have hidden too many imports in the examples though 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the liberty of updating the other sub resource documentation examples as well.
appreciate it!
Might have hidden too many imports in the examples though 🤔
eh, yeah maybe. i would have left the k8s_openapi
and kube
imports visible but it's not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roger that, I have left them visible now.
80acece
to
3e12621
Compare
0f208b6
to
22b3ed7
Compare
6713fee
to
c9503d5
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Just checking in, is there anything I am missing before the next round of review? :) If you are just busy then there is no rush 👍 , just wanted to make sure that you weren't waiting for me to do something. I will have another look at the failing CI and versioning guarding the tests. |
Ah, sorry, I have been a bit busy. Tons of PRs for 0.81 (which i plan on releasing today). |
Don't worry about that. I expect it will be gone after an update, but it can be resolved separately. The deny dependency duplication is a bit annoying for CI since it can break randomly - but it is useful info for us. |
82512c7
to
ca06b4c
Compare
I had to focus on uni for a bit. Will get back on this now. |
5d606df
to
1c2b97e
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1153 +/- ##
==========================================
- Coverage 73.28% 72.55% -0.74%
==========================================
Files 75 75
Lines 6057 6136 +79
==========================================
+ Hits 4439 4452 +13
- Misses 1618 1684 +66
|
4e04242
to
6125f4a
Compare
kube-core/src/params.rs
Outdated
/// let invalid_patch: PodSpec = serde_json::from_value(serde_json::json!({ | ||
/// "activeDeadlineSeconds": 5 | ||
/// }))?; | ||
/// | ||
/// // This will have no effect on mypod. | ||
/// pods.patch("mypod", &pp, &Patch::Strategic(invalid_patch)).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a future note to self: I am guessing this happens because activeDeadlineSeconds
is not a field on the top level struct expected in the patch on the go side, and thus once it's deserialized, the apiserver is simply asked to do an empty patch, which should never be an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly!
This commit implements replace, patch and get operations for the ephemeral containers subresource. Signed-off-by: Jessie Chatham Spencer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thank you so much. Appreciate the perseverance through the amount of annoyingly complex details that arose in here.
Motivation
Implement support for another sub resource, as described in #127.
Solution
Support for the ephemeral containers subresource is implemented using a marker
trait
Ephemeral
, which is implemented for thePod
struct. Three methods are implemented forApi<K>
whereK
is bounded with theEphemeral
trait,replace_ephemeral_containers
,patch_ephemeral_containers
andget_ephemeral_containers
. These methods correlate with the operations described in the Kubernetes API, see the section on EphemeralContainers Operations.Questions
I have a few questions before this should be merged.